package com.kobe.algorithm.leetcode.case11;

/**
 * @author ：caopengfei
 * @date ：2021/2/24
 */
public class Solution {

    public int maxArea(int[] height) {
        int maxWater = 0;
        int left = 0 ,right= height.length-1;
        while(left < right){
            int tempMaxWater = Math.min(height[left],height[right])*(right-left);
            if(height[left] < height[right]){
                ++left;
            }else{
                --right;
            }

            maxWater = Math.max(tempMaxWater,maxWater);
        }
        return maxWater;
    }

    public static void main(String[] args) {
        int[] arr = {1,8,6,2,5,4,8,3,7};
        Solution solution = new Solution();
        System.out.println(solution.maxArea(arr));
    }
}
